#include "window.h"
#include "ui_window.h"

Window::Window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Window)
{
    ui->setupUi(this);
    connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(enterButtonPressed()));
    this->setWindowTitle("TextQuest");
}

Window::~Window()
{
    delete ui;
}

void Window::enterButtonPressed()
{
    QString str = this->ui->lineEdit->text();
    this->ui->lineEdit->clear();
    emit(dataFromLineEdit(str));
}

void Window::keyPressEvent(QKeyEvent *e)
{
    switch(e->key())
    {
        case Qt::Key_Return:
            enterButtonPressed();
            break;
        case Qt::Key_Enter:
            enterButtonPressed();
            break;
    }
}

